﻿//-------------------------------------------------------------------------------
// <copyright file="FBPermissionDeniedException.cs" company="TaskyMedia LLC">
//     Copyright (c) TaskyMedia LLC.
// </copyright>
//-------------------------------------------------------------------------------

/*
 * Copyright (c) 2010, TaskyMedia LLC
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *   Redistributions of source code must retain the above copyright notice, this 
 *     list of conditions and the following disclaimer.
 *   Redistributions in binary form must reproduce the above copyright notice, this
 *     list of conditions and the following disclaimer in the documentation and/or
 *     other materials provided with the distribution.
 *   Neither the name of TaskyMedia LLC nor the names of its contributors may be used
 *   to endorse or promote products derived from this software without specific prior
 *   written permission.
 *   
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE. 
 */

namespace FBGraphApi
{
    using System;

    /// <summary>
    /// Exception thrown when the application attempts to access a resource (such as a
    /// property or connection) that it has not requested permissions for.
    /// </summary>
    public class FBPermissionDeniedException : ApplicationException
    {
        /// <summary>
        /// Exception message format string.
        /// </summary>
        private const string EXCEPTION_MESSAGE_FORMAT = "The application attempted to access a resource (such as a property or connection) for which it has not requested permission; name: '{0}'";

        /// <summary>
        /// The name of the resource that failed the permission validation.
        /// </summary>
        private string _resourceName;

        /// <summary>
        /// Initializes a new instance of the <see cref="FBPermissionDeniedException"/> class.
        /// </summary>
        /// <param name="resourceName">The name of the resource.</param>
        public FBPermissionDeniedException(string resourceName)
        {
            this._resourceName = resourceName;
        }

        /// <summary>
        /// Gets the name of the resource that failed the permission validation.
        /// </summary>
        /// <value>The name of the resource.</value>
        public string ResourceName
        {
            get
            {
                return this._resourceName;
            }
        }

        /// <summary>
        /// Gets a message that describes the current exception.
        /// </summary>
        /// <value></value>
        /// <returns>The error message that explains the reason for the exception, or an empty string("").</returns>
        public override string Message
        {
            get
            {
                return String.Format(EXCEPTION_MESSAGE_FORMAT, this._resourceName);
            }
        }
    }
}
